package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.mapper.entity.AdTransaction;
import com.example.demo.mapper.entity.Advertiser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface AdWalletMapper extends BaseMapper<AdTransaction> {
    @Select("select balance from advertiser where user_id = #{userId}")
    double selectRemainingSum(int userId);
    @Select("select * from advertiser where user_id = #{userId}")
    int selectAdvertiser(int userId);
    @Update("update advertiser set balance = balance + #{balance} where user_id = #{userId}")
    void addAmount(Advertiser advertiser);
    @Update("update advertiser set balance = balance - #{balance} where advertiser_id = #{advertiserId}")
    void minusAmount(Advertiser advertiser);



}
